layui.use(['layer', 'form', 'table', 'admin', 'ax', 'func', 'tree'], function () {
    var $ = layui.$;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;
    var tree = layui.tree;

    /**
     * 系统管理--消息管理
     */
    var Notice = {
        tableId: "noticeTable" ,   //表格id
        condition: {
            name:"",
            dd:"",
            status:""
        }
    };
    /**
     * 检索督导
     */
    // var languageAjax = new $ax(Feng.ctxPath + "/btyWage/getDm");
    // var languageResult = languageAjax.start();
    // $.each(languageResult, function (index, val) {
    //     $("#dm").append("<option value='" + val.dm + "'>" + val.dm + "</option>");
    // });
    // form.render('select');

    var ajax1 = new $ax(Feng.ctxPath + "/project/selectDdListAll", function (data) {
            var sb;
            for(let i = 0; i < data.length; i++) {
                sb+='<option value="'+data[i].tel+'">' + data[i].dd + '</option>';
            }
            $("#dd").append(sb);
            form.render();
        }, function (data) {
            Feng.error(data.responseJSON.message);
        });
    ajax1.start();

    /**
     * 初始化表格的列
     */
    Notice.initColumn = function () {
        return [[
            {field: 'id', align: "center", hide: true, sort: true, title: 'id'},
            {align: 'center', type: "numbers", title: '序号'},
            {field: 'name', align: "center", sort: false, title: '工程名称'},
            {field: 'yyjlName', align: "center", sort: false, title: '营运经理'},
            {field: 'dd', align: "center", sort: false, title: '督导'},
            {field: 'tel', align: "center", sort: false, title: '督导联系方式'},
            {field: 'dzName', align: "center", sort: false, title: '店长'},
            {field: 'dzTel', align: "center", sort: false, title: '店长联系方式'},
            {field: 'address', align: "center", sort: false, title: '门店地址'},
            {field: 'ygDate', align: "center", sort: false, title: '预计开业时间'},
            {field: 'sta', align: "center", sort: false, title: '开店状态'}
        ]];

    };

    /**
     * 点击查询按钮
     */
    Notice.search = function () {
        var queryData = {};
        queryData['name'] = $("#name").val();
        queryData['dd'] = $("#dd").val();
        queryData['status'] = $("#status").val();
        table.reload(Notice.tableId, {
            where: queryData, page: {curr: 1}
        });
    };


    // 渲染表格
    var tableResult = table.render({
        elem: '#' + Notice.tableId,
        url: Feng.ctxPath + '/project/sYList',
        page: true,
        height: "full-98",
        cellMinWidth: 100,
        limit: 20,
        cols: Notice.initColumn(),
    });



    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        Notice.search();
    });



    // 工具条点击事件
    table.on('tool(' + Notice.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;

        if (layEvent === 'edit') {
            Notice.onEditNotice(data);
        } else if (layEvent === 'delete') {
            Notice.onDeleteNotice(data);
        }
    });
});
